home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb7.arc
/
DATETIME.INC
< prev
next >
Wrap
Text File
|
1984-11-04
|
2KB
|
87 lines
{*
Datetime.prg
------------
Turbo pascal does not have date or time functions as BASIC (DATE$ TIME$)
in many business programs it is necessary to have at least the date , the time
is also very useful in all sorts of programs.
I have written here both date and time functions you can use in any of your
Turbo pascal programs either by using the I compiler directive for include ,
for example [$I datetime.prg], or by writing the functions in your programs.
try this sample program.
program sample;
[$I datetime.prg] (change '[' to '{' .)
begin
writeln;
write('The date is ',date,' and the time is ',time);
end.
Writen by Pinchas Gubits
4016 18th Ave.
Brooklyn NY 11218
*}
program datetime;
type
sd = string[10];
st = string[8];
function date : sd;
type
registors = record
ax,bx,cx,dx,bp,si,ds,es,flags: integer;
end;
var
regisrec : registors;
month , day : string[2];
year : string[4];
cx , dx : integer;
begin
with regisrec do
begin
ax := $2A shl 8;
end;
msdos(regisrec);
with regisrec do
begin
str(cx , year);
str(dx mod 256 , day);
str(dx shr 8 , month);
end;
if length(month) = 1 then insert(' ',month,1);
if length(day ) = 1 then insert('0',day,1 );
date := month + '-' + day + '-' + year;
end;
function time : st;
type
registors = record
ax,bx,cx,dx,bp,si,ds,es,flags: integer;
end;
var
regisrec : registors;
hour , minute , second : string[2];
cx , dx : integer;
begin
with regisrec do
begin
ax := $2C shl 8;
end;
msdos(regisrec);
with regisrec do
begin
str(cx shr 8 , hour);
str(cx mod 256 , minute);
str(dx shr 8 , second);
end;
if length(hour ) = 1 then insert(' ',hour ,1);
if length(minute) = 1 then insert('0',minute,1);
if length(second) = 1 then insert('0',second,1);
time := hour + ':' + minute + ':' + second
end;